<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
    <xsl:param name="DOTNET2"/>
    
  <xsl:template name="replace-string">
    <xsl:param name="text"/>
    <xsl:param name="replace"/>
    <xsl:param name="with"/>
    <xsl:choose>
      <xsl:when test="contains($text,$replace)">
        <xsl:value-of select="substring-before($text,$replace)"/>
        <xsl:value-of select="$with"/>
        <xsl:call-template name="replace-string">
          <xsl:with-param name="text" select="substring-after($text,$replace)"/>
          <xsl:with-param name="replace" select="$replace"/>
          <xsl:with-param name="with" select="$with"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
  
	<xsl:template match="Class"><xsl:variable name="Name" select="Name"/>
        <xsl:variable name="HeaderInfo" select="HeaderInfo/ProjectName"/>

// ***************************************************************
// Automatically generated from CodeGen2007 
// Project Name: <xsl:value-of select="HeaderInfo/ProjectName"/>
// Prefix: <xsl:value-of select="HeaderInfo/Prefix"/>
// ***************************************************************

#define PARAMFULL


using System;
using System.Xml;
using System.Xml.Serialization;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

#if(AJAX)
using AjaxStub;
#endif

#if(AJAXPRO)
using AjaxPro;
#endif

namespace <xsl:value-of select="HeaderInfo/ProjectName"/>.DataObject  {


	[ Serializable ]
	#if(AJAX)
	[ AjaxStub.GRB.ComplexType () ]
	#endif
	<xsl:for-each select="ClassAttribs/ClassAttributes">
	<xsl:if test="KnownClass='true'">
	[ XmlInclude ( typeof(<xsl:value-of select="Type"/> ) ) ]<xsl:text>&#xD;&#9;</xsl:text>
	</xsl:if>
	</xsl:for-each>
	public class <xsl:value-of select="Name"/> : <xsl:value-of select="HeaderInfo/ProjectName"/>DataObject, IComparable {
		
		
#region DOS Class
		/* 
			This is a special class which provides simple types that works
			with ASP.NET DataObjectSource style controls
		*/
		
		public class <xsl:value-of select="Name"/>DOS : <xsl:value-of select="HeaderInfo/ProjectName"/>DOS
		{
			<xsl:for-each select="ClassAttribs/ClassAttributes">
				<xsl:if test="CType='single'">
					<xsl:if test="KnownClass='true'">
			private Guid <xsl:value-of select="Name"/>;
			public Guid <xsl:value-of select="PropertyName"/> { 
				get { return <xsl:value-of select="Name"/>; }
				set { <xsl:value-of select="Name"/> = value; }
			}
					</xsl:if>
					
					<xsl:if test="KnownClass='false'">
			private <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="Name"/>;
			public <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="PropertyName"/> {
				get { return <xsl:value-of select="Name"/>; }
				set { <xsl:value-of select="Name"/> = value; }
			}
					</xsl:if>
					
				</xsl:if>
				
				<xsl:if test="CType='array'">
					<xsl:if test="KnownClass='true'">
			private Guid[] <xsl:value-of select="Name"/>;
			public Guid[] <xsl:value-of select="PropertyName"/> { 
				get { return <xsl:value-of select="Name"/>; }
				set { <xsl:value-of select="Name"/> = value; }
			}
					</xsl:if>
					
					<xsl:if test="KnownClass='false'">
			private <xsl:value-of select="Type"/>[] <xsl:value-of select="Name"/>;
			public <xsl:value-of select="Type"/>[] <xsl:value-of select="PropertyName"/> {
				get { return <xsl:value-of select="Name"/>; }
				set { <xsl:value-of select="Name"/> = value; }
			}
					</xsl:if>
				</xsl:if>
				

			</xsl:for-each>
			
			
			
			public <xsl:value-of select="Name"/>DOS ToDos ( <xsl:value-of select="Name"/> fromObj )
			{
				<xsl:value-of select="Name"/>DOS toObj = new <xsl:value-of select="Name"/>DOS ();
				
				toObj.ObjectID = fromObj.ObjectID;
				toObj.ModifiedDate = fromObj.ModifiedDate;
				toObj.CreatedDate = fromObj.CreatedDate;

				<xsl:for-each select="ClassAttribs/ClassAttributes">
					<xsl:if test="CType='single'">
						<xsl:if test="KnownClass='true'">
						toObj.<xsl:value-of select="PropertyName"/>=
							fromObj.<xsl:value-of select="PropertyName"/>.ObjectID;
						</xsl:if>
						
						<xsl:if test="KnownClass='false'">
						toObj.<xsl:value-of select="PropertyName"/>=
							fromObj.<xsl:value-of select="PropertyName"/>;
						</xsl:if>
					</xsl:if>
					
					<xsl:if test="CType='array'">
						<xsl:if test="KnownClass='true'">
						
						List&lt;Guid&gt; <xsl:value-of select="PropertyName"/> = new
								List&lt;Guid&gt; ();
						foreach ( <xsl:value-of select="Type"/> o in fromObj.<xsl:value-of select="PropertyName"/> )
						{
							<xsl:value-of select="PropertyName"/>.Add ( o.ObjectID );
						}
						
						toObj.<xsl:value-of select="PropertyName"/> = <xsl:value-of select="PropertyName"/>.ToArray ();
						</xsl:if>
						
						<xsl:if test="KnownClass='false'">
						List&lt;<xsl:value-of select="Type"/>&gt; <xsl:value-of select="PropertyName"/> = new
								List&lt;<xsl:value-of select="Type"/>&gt; ();
						foreach ( <xsl:value-of select="Type"/> o in fromObj.<xsl:value-of select="PropertyName"/> )
						{
							<xsl:value-of select="PropertyName"/>.Add ( o );
						}
						
						toObj.<xsl:value-of select="PropertyName"/> = <xsl:value-of select="PropertyName"/>.ToArray ();
						
						</xsl:if>
					</xsl:if>
				</xsl:for-each>
				
				return toObj;
			}
			
			public <xsl:value-of select="Name"/> FromDos ( <xsl:value-of select="Name"/>DOS fromObj )
			{
				<xsl:value-of select="Name"/> toObj = new <xsl:value-of select="Name"/> ();
				
				toObj.ObjectID = fromObj.ObjectID;
				toObj.ModifiedDate = fromObj.ModifiedDate;
				toObj.CreatedDate = fromObj.CreatedDate;
				
				<xsl:for-each select="ClassAttribs/ClassAttributes">
					<xsl:if test="CType='single'">
						<xsl:if test="KnownClass='true'">
						
						if ( fromObj.<xsl:value-of select="PropertyName"/> != null ) {
						toObj.<xsl:value-of select="PropertyName"/>=new <xsl:value-of select="Type"/> (
							fromObj.<xsl:value-of select="PropertyName"/>);
						}
						</xsl:if>
						
						<xsl:if test="KnownClass='false'">
						if ( fromObj.<xsl:value-of select="PropertyName"/> != null )
						{
							toObj.<xsl:value-of select="PropertyName"/>=
								fromObj.<xsl:value-of select="PropertyName"/>;
						}
						</xsl:if>
					</xsl:if>
					
					<xsl:if test="CType='array'">
						<xsl:if test="KnownClass='true'">
						
						if ( fromObj.<xsl:value-of select="PropertyName"/> != null ){
						foreach ( Guid o in fromObj.<xsl:value-of select="PropertyName"/> )
						{
							toObj.<xsl:value-of select="PropertyName"/>.Add ( new <xsl:value-of select="Type"/> ( o ) );
						}
						}
						
						</xsl:if>
						
						<xsl:if test="KnownClass='false'">
						if ( fromObj.<xsl:value-of select="PropertyName"/> != null ) {
						foreach ( <xsl:value-of select="Type"/> o in fromObj.<xsl:value-of select="PropertyName"/> )
						{
							toObj.<xsl:value-of select="PropertyName"/>.Add (  o  );
						}
						}
						</xsl:if>
					</xsl:if>
				</xsl:for-each>

				return toObj;
				
			}
			
			
			public <xsl:value-of select="Name"/>DOS[] Select ()
			{
				return Select ( 10, 0 );
			}
			
			public <xsl:value-of select="Name"/>DOS[] Select ( string filter )
			{
				List&lt;<xsl:value-of select="Name"/>DOS&gt; objArray =
					new List&lt;<xsl:value-of select="Name"/>DOS&gt;();
				foreach ( <xsl:value-of select="Name"/> obj in
					<xsl:value-of select="Name"/>.LoadUsingSQL ( filter ) )
				{
					objArray.Add ( ToDos ( obj ) );
				}
				
				return objArray.ToArray ();			
			}
			
			
			public static <xsl:value-of select="Name"/>DOS Load ( Guid id )
			{
				return new <xsl:value-of select="Name"/>DOS().ToDos ( new <xsl:value-of select="Name"/>(id) );
			}
			
			public bool Save ( <xsl:value-of select="Name"/>DOS obj )
			{
				return new <xsl:value-of select="Name"/>().Save ( FromDos ( obj ) );
			}
			
			public <xsl:value-of select="Name"/>DOS[] Select ( int max , int start )
			{
				List&lt;<xsl:value-of select="Name"/>DOS&gt; objArray =
					new List&lt;<xsl:value-of select="Name"/>DOS&gt;();
				foreach ( <xsl:value-of select="Name"/> obj in
					new <xsl:value-of select="Name"/>().Get ( string.Empty , max , start ) )
				{
					objArray.Add ( ToDos ( obj ) );
				}
				
				return objArray.ToArray ();
			}
			
			public <xsl:value-of select="Name"/>DOS[] Select ( string filter , int max , int start )
			{
				List&lt;<xsl:value-of select="Name"/>DOS&gt; objArray =
					new List&lt;<xsl:value-of select="Name"/>DOS&gt;();
				foreach ( <xsl:value-of select="Name"/> obj in
					new <xsl:value-of select="Name"/>().Get ( filter , max , start ) )
				{ 
					objArray.Add ( ToDos ( obj ) );
				}
				
				return objArray.ToArray ();			
			}
			
			public <xsl:value-of select="Name"/>DOS[] Select ( string filter , string sort, int max , int start )
			{
				List&lt;<xsl:value-of select="Name"/>DOS&gt; objArray =
					new List&lt;<xsl:value-of select="Name"/>DOS&gt;();
				foreach ( <xsl:value-of select="Name"/> obj in
					new <xsl:value-of select="Name"/>().Select ( filter , sort , max , start ) )
				{ 
					objArray.Add ( ToDos ( obj ) );
				}
				
				return objArray.ToArray ();			
			}
			
			public int SelectCount ( string filter , string sort ) { return SelectCount ( filter ); }
			
			public int SelectCount ( string filter )
			{
				return new <xsl:value-of select="Name"/>().SelectCount ( filter );
			}
			
			public int SelectCount () { return new <xsl:value-of select="Name"/>().SelectCount ( string.Empty ); }
			
			public bool Delete ( <xsl:value-of select="Name"/>DOS obj )
			{
				return new <xsl:value-of select="Name"/> ( obj.ObjectID ).delete();
			}
		
		}

#endregion
		
		public <xsl:value-of select="Name"/> () : base() { }
			
		public <xsl:value-of select="Name"/> ( Guid objectID ) : this () {
			Load ( objectID );
		}
		
		public <xsl:value-of select="Name"/> ( Guid objectID , bool audit ) : this () {
			Load ( objectID , audit );
		}
		
		public <xsl:value-of select="Name"/> ( Guid objectID,
		    int timezoneOffset ) : this( timezoneOffset ) {
				Load ( objectID );
		}
		
		
		
		// timezone specific constructor
		public <xsl:value-of select="Name"/> ( int timezoneOffset ) 
			    : base( timezoneOffset ) {
		
		}
		
		// ASP.NET 2.0 control purposes
		public bool Save ( <xsl:value-of select="Name"/> obj )
		{
			// TODO: Here make a way of ensuring we do not loose values as
			// the Obj is only partially there.
			obj.dirty = true;
			return obj.Save();
		}
		
		// ASP.NET 2.0 control purposes
		public bool Delete ( <xsl:value-of select="Name"/> obj )
		{
			return obj.delete();
		}
		
		// ASP.NET 2.0 control purposes
		public <xsl:value-of select="Name"/> LoadUnique ( Guid objectID )
		{
			return new <xsl:value-of select="Name"/> ( objectID );
		}
		
		public int SelectCount ()
		{
			return SelectCount ( string.Empty );
		}
		
		
		public override <xsl:value-of select="HeaderInfo/ProjectName"/>DataObject LoadSingle ( Guid objectID )
		{
			return ( <xsl:value-of select="HeaderInfo/ProjectName"/>DataObject ) 
				new <xsl:value-of select="Name"/> ( objectID );
		}
		
		
		
		


		
		
		public int SelectCount ( string filter )
		{
			int resultCount = 0;
			try
			{
				using( SqlConnection sqlCon=new SqlConnection( <xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB () ) ) {
					sqlCon.Open ();
					using ( SqlCommand sqlCom = new SqlCommand ( "SELECT COUNT(<xsl:value-of select="Name"/>ID) FROM [<xsl:value-of select="Name"/>] " + (filter.Equals ( string.Empty ) ? "" : "WHERE ") + filter , sqlCon ) )
					{
						resultCount = (int) sqlCom.ExecuteScalar ();
					}
					sqlCon.Close ();
				}
			
			}
			catch ( Exception ex )
			{
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException ( ex );
			}
			
			return resultCount;
		}
		
		public <xsl:value-of select="Name"/>[] Get ( int max , int start )
		{
			return Select ( string.Empty , string.Empty , max , start );
		}
		
		public <xsl:value-of select="Name"/>[] Get ( string filter , int max , int start )
		{
			return Select ( filter , string.Empty , max , start );
		}
		
		
		
		public <xsl:value-of select="Name"/>[] Select ( string filter , string sort , int max , int start )
		{
			int pageSize = max;
			int pageNumber = start == 0 ? 1 : ( start / max ) + 1 ;
		
			ArrayList alResults = new ArrayList ();
			try 
			{
				
				using( SqlConnection sqlCon=new SqlConnection( <xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB () ) ) {
					sqlCon.Open ();
					using ( SqlCommand sqlCom = new SqlCommand ( "Paging_RowCount" , sqlCon ) ) {
						sqlCom.CommandType = CommandType.StoredProcedure;
						sqlCom.Parameters.Add ( "@Tables", "<xsl:value-of select="Name"/>" );
						sqlCom.Parameters.Add ( "@PK", "<xsl:value-of select="Name"/>Id" );
						sqlCom.Parameters.Add ( "@Fields", "<xsl:value-of select="Name"/>Id" );
						sqlCom.Parameters.Add ( "@Filter", filter );
						sqlCom.Parameters.Add ( "@PageNumber", pageNumber );
						sqlCom.Parameters.Add ( "@PageSize", pageSize );
						sqlCom.Parameters.Add ( "@Sort", sort );
						
						using ( SqlDataReader sqlDr = sqlCom.ExecuteReader () )
						{
							while ( sqlDr.Read () )
							{
								alResults.Add ( new <xsl:value-of select="Name"/> ( sqlDr.GetGuid ( 0 ) ) );
							}
						}
					}
					sqlCon.Close ();
				}
			}
			catch ( Exception ex ) 
			{
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException ( ex );
			}
			
			return ( <xsl:value-of select="Name"/>[] ) alResults.ToArray ( typeof ( <xsl:value-of select="Name"/> ) );
		}
		
		
		public <xsl:value-of select="Name"/> LastObject ()
		{
			<xsl:value-of select="Name"/>[] objs = 
				<xsl:value-of select="Name"/>.LoadUsingFullSQL ( string.Format ( "select top 1 <xsl:value-of select="Name"/>ID from " +
					"<xsl:value-of select="Name"/> where <xsl:value-of select="Name"/>ID='{0}' order by created desc" , this.ObjectID ) );
				
			if ( objs.Length == 1 ) return objs [ 0 ];
			
			return new <xsl:value-of select="Name"/> ();
		}

		public static <xsl:value-of select="Name"/>[] LoadUsingFullSQL ( string query )
		{
			ArrayList alResults = new ArrayList ();
			try 
			{
				using( SqlConnection sqlCon=new SqlConnection( <xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB () ) ) {
					sqlCon.Open ();
					using ( SqlCommand sqlCom = new SqlCommand ( query , sqlCon ) ) {
						using ( SqlDataReader sqlDr = sqlCom.ExecuteReader () )
						{
							while ( sqlDr.Read () )
							{
								alResults.Add ( new <xsl:value-of select="Name"/> ( sqlDr.GetGuid ( 0 ) ) );
							}
						}
					
					}
				}
			
			
			}
			catch ( Exception ex )
			{
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException ( ex );
				
				throw ex;
			}
			
			return ( <xsl:value-of select="Name"/> [] ) alResults.ToArray ( typeof ( <xsl:value-of select="Name"/> ) );
		
		}
		
		public static <xsl:value-of select="Name"/>[] LoadUsingSQL ( string query )
		{
			ArrayList alResults = new ArrayList ();
			try 
			{
				using( SqlConnection sqlCon=new SqlConnection( <xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB () ) ) {
					sqlCon.Open ();
					using ( SqlCommand sqlCom = new SqlCommand ( "SELECT <xsl:value-of select="Name"/>ID FROM [<xsl:value-of select="Name"/>] " +
					(query.Equals ( String.Empty ) ? "" : "WHERE ") + query , sqlCon ) ) {
						using ( SqlDataReader sqlDr = sqlCom.ExecuteReader () )
						{
							while ( sqlDr.Read () )
							{
								alResults.Add ( new <xsl:value-of select="Name"/> ( sqlDr.GetGuid ( 0 ) ) );
							}
						}
					
					}
				}
			
			
			}
			catch ( Exception ex )
			{
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException ( ex );
				
				throw ex;
			}
			
			return ( <xsl:value-of select="Name"/> [] ) alResults.ToArray ( typeof ( <xsl:value-of select="Name"/> ) );
		
		}
		
		
		[ Summary( "Load a <xsl:value-of select="Name"/> object" ) ]
		public override bool Load ( Guid objectID , bool audit ) {
			bool isRead=false;
			try {
				base.ObjectID=objectID;
				using( SqlConnection sqlCon=new SqlConnection( <xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB () ) ) {
					sqlCon.Open ();
					using ( SqlCommand sqlCom = new SqlCommand ( "GENSP_<xsl:value-of select="HeaderInfo/Prefix"/>_<xsl:value-of select="Name"/>Select" + (audit?"_Audit":string.Empty), sqlCon ) ) {
						sqlCom.CommandType = CommandType.StoredProcedure;
						sqlCom.Parameters.Add ( "@<xsl:value-of select="Name"/>ID" ,base.ObjectID );
						using ( SqlDataReader sqlDr = sqlCom.ExecuteReader () ) 
						{
							if ( isRead = sqlDr.Read () ) 
							{
								<xsl:value-of select="Name"/> _<xsl:value-of select="Name"/> = new <xsl:value-of select="Name"/> ();
								ObjectID = (Guid) sqlDr [ "<xsl:value-of select="Name"/>ID" ];
								base.setDefaults ( this , sqlDr );
				
				
				
				
				<xsl:for-each select="ClassAttribs/ClassAttributes">
								    <!--<xsl:variable name="accessMethod">
										<xsl:call-template name="replace-string"> 
											<xsl:with-param name="text" select="SqlAccess"/>
											<xsl:with-param name="replace" select="'x'"/>
											<xsl:with-param name="with" select="position()+2"/>
										</xsl:call-template>
									</xsl:variable>
									<xsl:if test="CType='single'">
									<xsl:if test="KnownClass='false'"><xsl:value-of select="Name"/>=<xsl:if test="IsEnum='true'">(<xsl:value-of select="Type"/>)</xsl:if>sqlDr.<xsl:value-of select="$accessMethod"/>;</xsl:if>
									<xsl:if test="KnownClass='true'"><xsl:value-of select="Name"/>=new <xsl:value-of select="Type"/>(sqlDr.<xsl:value-of select="$accessMethod"/>);</xsl:if>
									    <xsl:text>&#xD;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;</xsl:text> 
				    </xsl:if>-->
				    
				    <xsl:if test="CType='single'">
					<xsl:if test="KnownClass='false'">
					    <xsl:if test="Type!='bool'">
								<xsl:value-of select="Name"/> = ( <xsl:value-of select="Type"/> ) sqlDr[ "<xsl:value-of select="Name"/>" ];
					    </xsl:if>          
					    
					    <xsl:if test="Type='bool'">
								<xsl:value-of select="Name"/> = ( bool ) ( ( ( byte ) sqlDr[ "<xsl:value-of select="Name"/>" ] ) == 1 );
					    </xsl:if>
					</xsl:if>
					<xsl:if test="KnownClass='true'">
					    <xsl:value-of select="Name"/> = new <xsl:value-of select="Type"/> ( ( Guid ) sqlDr[ "<xsl:value-of select="Name"/>" ] );
					</xsl:if>
					<xsl:text>&#xD;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;</xsl:text> 
				    </xsl:if>
				    
								</xsl:for-each>
								
								<xsl:for-each select="ClassAttribs/ClassAttributes">
								<xsl:if test="CType='array'">
								sqlDr.NextResult ();
								<xsl:value-of select="Name"/> = new ArrayList ();
								while ( sqlDr.Read () ) 
								{
									<xsl:if test="Type!='Guid'">
										<xsl:value-of select="Name"/>.Add( new <xsl:value-of select="Type"/> ( sqlDr.GetGuid ( 0 ) ) );
									</xsl:if>
									
									<xsl:if test="Type='Guid'">
										<xsl:value-of select="Name"/>.Add ( sqlDr.GetGuid ( 0 ) );
									</xsl:if>
								}	
								</xsl:if>
								</xsl:for-each>								
							}							
						}
					}
					sqlCon.Close ();
				}
			} catch ( Exception ex ) {
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException ( ex );
			}
			return isRead;	
		}
		
		
		protected override bool isLatest ( System.Data.SqlClient.SqlConnection sqlCon )
		{
			DateTime modified = DateTime.Now;
			try 
			{
				using ( SqlCommand sqlCom = new SqlCommand ( "SELECT modified FROM [<xsl:value-of select="Name"/>] " +
					" WHERE <xsl:value-of select="Name"/>Id = '" + this.ObjectID + "'" ) )
				{
					modified = ( DateTime ) sqlCom.ExecuteScalar ();
				}			
			
			}
			catch ( Exception ex )
			{
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException ( ex );
			}
			
			return modified == this.modifiedDate;
		}
		
		
		protected override bool insert ( System.Data.SqlClient.SqlConnection sqlCon )
		{
			return insert ( sqlCon , false );
		}
		
		protected override bool insert ( System.Data.SqlClient.SqlConnection sqlCon , bool isAudit ) {
			//this.objectID=Guid.NewGuid();
			int retVal = 0;
			try {
				if ( isAudit )
				{
					using ( SqlCommand sqlCom = new SqlCommand ( string.Format ( "delete from <xsl:value-of select="Name"/>_Audit where <xsl:value-of select="Name"/>ID='{0}'" , base.ObjectID ) , sqlCon ) )
					{
						sqlCom.ExecuteNonQuery ();
					}
				}
			
			
				using ( SqlCommand sqlCom = new SqlCommand ( 
					"GENSP_<xsl:value-of select="HeaderInfo/Prefix"/>_<xsl:value-of select="Name"/>Insert" + 
					(isAudit?"_Audit":"") , sqlCon ) ) 
				{
					sqlCom.CommandType = CommandType.StoredProcedure;
					sqlCom.Parameters.Add ( "@<xsl:value-of select="Name"/>ID" , base.ObjectID );
					<xsl:for-each select="ClassAttribs/ClassAttributes">
					<xsl:if test="CType='single'">
					<xsl:if test="KnownClass='false'">sqlCom.Parameters.Add ( 
						"@<xsl:value-of select="Name"/>" , this.<xsl:value-of select="Name"/> );</xsl:if>
					<xsl:if test="KnownClass='true'">sqlCom.Parameters.Add ( "@<xsl:value-of select="Name"/>" , 
					this.<xsl:value-of select="Name"/>.ObjectID );</xsl:if>
					</xsl:if><xsl:text>&#xD;&#9;&#9;&#9;&#9;&#9;</xsl:text> 
					</xsl:for-each>
					retVal = sqlCom.ExecuteNonQuery ();
				}
				
				
				// Do not audit the array stuff
				if ( ! isAudit )
				{
					<xsl:for-each select="ClassAttribs/ClassAttributes">
					<xsl:if test="CType='array'">
					using ( SqlCommand sqlCom = new SqlCommand ( "GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>Delete" ,sqlCon ) ) 
					{
						sqlCom.CommandType = CommandType.StoredProcedure;
						sqlCom.Parameters.Add ( "@<xsl:value-of select="$Name"/>ID" , base.ObjectID );
						sqlCom.ExecuteNonQuery ();
					}	
					
					foreach ( <xsl:value-of select="Type"/> _<xsl:value-of select="Type"/> in <xsl:value-of select="Name"/> ) {
						using (SqlCommand sqlCom = new SqlCommand ( "GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>Insert" , sqlCon ) ) 
						{
							sqlCom.CommandType = CommandType.StoredProcedure;
							sqlCom.Parameters.Add ( "@<xsl:value-of select="$Name"/>ID" , base.ObjectID );
							<xsl:if test="Type!='Guid'">
							sqlCom.Parameters.Add ( "@<xsl:value-of select="Type"/>bID" , _<xsl:value-of select="Type"/>.ObjectID );
							</xsl:if>
							<xsl:if test="Type='Guid'">
							sqlCom.Parameters.Add ( "@<xsl:value-of select="Type"/>bID" , _<xsl:value-of select="Type"/> );
							</xsl:if>						
							sqlCom.ExecuteNonQuery ();
						}
					}
					</xsl:if>
					</xsl:for-each>
				}
				
			} catch ( Exception ex ) {
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException ( ex );
				return false;
			}
			
			if ( retVal > 0 ) writeAudit ( ModType.Insert );
			
			return retVal > 0;
		}
		
		protected override bool update(System.Data.SqlClient.SqlConnection sqlCon) {
			int retVal=0;
			try {
				using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="HeaderInfo/Prefix"/>_<xsl:value-of select="Name"/>Update",sqlCon)) {
					sqlCom.CommandType=CommandType.StoredProcedure;
					sqlCom.Parameters.Add("@<xsl:value-of select="Name"/>ID",base.ObjectID);
					<xsl:for-each select="ClassAttribs/ClassAttributes">
					<xsl:if test="CType='single'">
					<xsl:if test="KnownClass='false'">sqlCom.Parameters.Add("@<xsl:value-of select="Name"/>",this.<xsl:value-of select="Name"/>);</xsl:if>
					<xsl:if test="KnownClass='true'">sqlCom.Parameters.Add("@<xsl:value-of select="Name"/>",this.<xsl:value-of select="Name"/>.ObjectID);</xsl:if>
					</xsl:if><xsl:text>&#xD;&#9;&#9;&#9;&#9;&#9;</xsl:text> 
					</xsl:for-each>
					retVal=sqlCom.ExecuteNonQuery();
				}
				
				<xsl:for-each select="ClassAttribs/ClassAttributes">
				<xsl:if test="CType='array'">
				using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>Delete",sqlCon)) {
					sqlCom.CommandType=CommandType.StoredProcedure;
					sqlCom.Parameters.Add("@<xsl:value-of select="$Name"/>ID",base.ObjectID);
					sqlCom.ExecuteNonQuery();
				}	
				
				foreach(<xsl:if test="Type='Guid'">string</xsl:if><xsl:if test="Type!='Guid'"><xsl:value-of select="Type"/></xsl:if> _<xsl:value-of select="Type"/> in <xsl:value-of select="Name"/>) {
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>Insert",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						sqlCom.Parameters.Add("@<xsl:value-of select="$Name"/>ID",base.ObjectID);
						<xsl:if test="Type!='Guid'">
						sqlCom.Parameters.Add("@<xsl:value-of select="Type"/>bID",_<xsl:value-of select="Type"/>.ObjectID);
						</xsl:if>
						<xsl:if test="Type='Guid'">
						sqlCom.Parameters.Add("@<xsl:value-of select="Type"/>bID",_<xsl:value-of select="Type"/>);
						</xsl:if>	
						sqlCom.ExecuteNonQuery();
					}
				}
				</xsl:if>
				</xsl:for-each>
			} catch(Exception ex) {
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
				return false;
			}
			
			if ( retVal > 0 ) writeAudit ( ModType.Update );
			
			return retVal>0;
		}
		
		public bool DeleteNoAudit () {
			int retVal=0;
			try {
				using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB())) {
					sqlCon.Open();
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="HeaderInfo/Prefix"/>_<xsl:value-of select="Name"/>Delete",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						sqlCom.Parameters.Add("@<xsl:value-of select="Name"/>ID",base.ObjectID);
						retVal=sqlCom.ExecuteNonQuery();
					}
					
					<xsl:for-each select="ClassAttribs/ClassAttributes">
					<xsl:if test="CType='array'">
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>Delete",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						sqlCom.Parameters.Add("@<xsl:value-of select="$Name"/>ID",base.ObjectID);
						sqlCom.ExecuteNonQuery();
					}					
					</xsl:if>
					</xsl:for-each>
					
					
					<xsl:for-each select="DeleteArrayObjs/DeleteArray">
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="OtherClass"/>_<xsl:value-of select="Name"/>DeleteRef",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						sqlCom.Parameters.Add("@<xsl:value-of select="Field"/>ID",base.ObjectID);
						sqlCom.ExecuteNonQuery();
					}							
					</xsl:for-each>
					
					
					
					sqlCon.Close();
				}
			} catch(Exception ex) {
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
				return false;
			}
			
			return retVal>0;
			
		}
		
		public override bool delete() {
			int retVal=0;
			try {
				using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB())) {
					sqlCon.Open();
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="HeaderInfo/Prefix"/>_<xsl:value-of select="Name"/>Delete",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						sqlCom.Parameters.Add("@<xsl:value-of select="Name"/>ID",base.ObjectID);
						retVal=sqlCom.ExecuteNonQuery();
					}
					
					<xsl:for-each select="ClassAttribs/ClassAttributes">
					<xsl:if test="CType='array'">
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>Delete",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						sqlCom.Parameters.Add("@<xsl:value-of select="$Name"/>ID",base.ObjectID);
						sqlCom.ExecuteNonQuery();
					}					
					</xsl:if>
					</xsl:for-each>
					
					
					<xsl:for-each select="DeleteArrayObjs/DeleteArray">
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="OtherClass"/>_<xsl:value-of select="Name"/>DeleteRef",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						sqlCom.Parameters.Add("@<xsl:value-of select="Field"/>ID",base.ObjectID);
						sqlCom.ExecuteNonQuery();
					}							
					</xsl:for-each>
					
					
					
					sqlCon.Close();
				}
			} catch(Exception ex) {
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
				return false;
			}
			
			if ( retVal > 0 ) writeAudit ( ModType.Delete );
			
			return retVal>0;
		}
		
		// this returns the amount of items in the database
		public static int GetCount() {
			int returnValues=0;
			try {
				using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB())) {
					sqlCon.Open();
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="HeaderInfo/Prefix"/>_<xsl:value-of select="Name"/>CountAll",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						returnValues=(int)sqlCom.ExecuteScalar();
					}
					sqlCon.Close();
				}				
			} catch(Exception ex) {
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
			}	
			return returnValues;
		}
		
		
		// this returns all of the instances of <xsl:value-of select="Name"/> from the database
		public static <xsl:value-of select="Name"/>[] Get() {
			ArrayList al<xsl:value-of select="Name"/>=new ArrayList();
			try {
				using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB())) {
					sqlCon.Open();
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="HeaderInfo/Prefix"/>_<xsl:value-of select="Name"/>SelectAll",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
							while(sqlDr.Read()) {
								al<xsl:value-of select="Name"/>.Add(new <xsl:value-of select="Name"/>(sqlDr.GetGuid(0)));
							}
						}
					}
					sqlCon.Close();
				}
			
			} catch(Exception ex) {
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
			}	
			return (<xsl:value-of select="Name"/>[])al<xsl:value-of select="Name"/>.ToArray(typeof(<xsl:value-of select="Name"/>));
		}
		
		
		public static int CountGet() {
			int x=0;
			try {
				using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB())) {
					sqlCon.Open();
					
					using(SqlCommand sqlCom=new SqlCommand("select count(*) from [<xsl:value-of select="Name"/>]",sqlCon)) {
						//sqlCom.CommandType=CommandType.StoredProcedure;
						//using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
						//	while(sqlDr.Read()) {
						//		x++;
						//	}
						//}
						
						
						
						x = (int)sqlCom.ExecuteScalar();
					}
					sqlCon.Close();
				}
			
			} catch(Exception ex) {
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
			}	
			return x;
		}
		
		public static <xsl:value-of select="Name"/>Small[] GetSmall() {
			ArrayList al<xsl:value-of select="Name"/>=new ArrayList();
			try {
				using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.GetDB())) {
					sqlCon.Open();
					using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="HeaderInfo/Prefix"/>_<xsl:value-of select="Name"/>SelectAll",sqlCon)) {
						sqlCom.CommandType=CommandType.StoredProcedure;
						using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
							while(sqlDr.Read()) {
								al<xsl:value-of select="Name"/>.Add(new <xsl:value-of select="Name"/>Small(new <xsl:value-of select="Name"/>(sqlDr.GetGuid(0))));
							}
						}
					}
					sqlCon.Close();
				}
			
			} catch(Exception ex) {
				<xsl:value-of select="HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
			}	
			return (<xsl:value-of select="Name"/>Small[])al<xsl:value-of select="Name"/>.ToArray(typeof(<xsl:value-of select="Name"/>Small));		
		}
		
        <xsl:for-each  select="ClassAttribs/ClassAttributes[ToString='true']">
        protected override Guid[] Get_ToString(object val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val.ToString());
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(sqlDr.GetGuid(0));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (Guid[])al<xsl:value-of select="$Name"/>.ToArray(typeof(Guid));
        }   
        </xsl:for-each>
        
        
        <xsl:if test="count(ClassAttribs/ClassAttributes[ToString='true'])=0">
            
        // this needs to exist because the SaveNoDupe() method requires it
        protected override Guid[] Get_ToString(object val) {
            return new Guid[0];
        }
            
        </xsl:if>
        
        
        
	<xsl:for-each select="ClassAttribs/ClassAttributes">
	
		<xsl:if test="KnownClass='true' and CType='single'">
		
		// Perform a reverse lookup using the Count thing
		
	public static int CountMatching<xsl:value-of select="PropertyName"/> ( Guid objectId )
	{
	
		
		return (int)
			<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ScalerQuery ( 
			"select count(*) from <xsl:value-of select="$Name"/> where <xsl:value-of select="Name"/>='" + objectId + "'" );
	
	}
		
		
		</xsl:if>
		
		
		<xsl:if test="CType='array'">

	public static int CountMatching<xsl:value-of select="PropertyName"/> ( Guid objectId )
	{
	
		
		return (int)
			<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ScalerQuery ( 
			"select count(*) from <xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/> where <xsl:value-of select="Type"/>bId='" + objectId + "'" );
	
	}


		
		</xsl:if>
		
		
	
	</xsl:for-each>
	
        
        #if(PARAMFULL)
        <xsl:for-each select="ClassAttribs/ClassAttributes">

            <xsl:if test="CType='single'">

                <xsl:choose>
                    <xsl:when test="Type='bool'">
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>(bool val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val?1:0);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }
                    </xsl:when>
                    
                    <xsl:when test="Type='DateTime'">
        // Get when date time equals
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>(DateTime val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }


        // Get when datetime is Before
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_Before(DateTime val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>_Before",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }
        
        
        // Get when datetime is After
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_After(DateTime val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>_After",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }
        
        
        // Get when datetime is Between
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_Between(DateTime start,DateTime end) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>_Between",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@start_",start);
                        sqlCom.Parameters.Add("@end_",end);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }
        
                    </xsl:when> 
		    
		    
		    <xsl:when test="KnownClass='true'">
		    
		    
	public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/> ( <xsl:value-of select="Type"/> obj )
	{
		return <xsl:value-of select="$Name"/>.LoadUsingSQL ( "[<xsl:value-of select="Name"/>] = '" + obj.ObjectID.ToString() + "'" );
	}
		    
		    
		    </xsl:when>

		    <xsl:when test="Type='Guid'">
	public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>(Guid val) 
	{
		return LoadUsingSQL ( "[<xsl:value-of select="PropertyName"/>] = '" + val.ToString() + "'" );
	}
	
	public static <xsl:value-of select="$Name"/> Get_<xsl:value-of select="PropertyName"/>_First ( Guid val )
	{
		<xsl:value-of select="$Name"/>[] vals = Get_<xsl:value-of select="PropertyName"/> ( val );
		if ( vals.Length &gt; 0 ) { return vals[0]; }
		else return null;
	}
		    
		    </xsl:when>
                    
                    <xsl:when test="Type='string' and SqlSPType!='ntext'">
                        
                        
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>(string val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }


		public static <xsl:value-of select="$Name"/> Get_<xsl:value-of select="PropertyName"/>_First(string val) {
			<xsl:value-of select="$Name"/>[] vals = Get_<xsl:value-of select="PropertyName"/> ( val );
			if ( vals.Length > 0 ) return vals[0]; else return null;
		}
        
        
        
        
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_Like(string val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>_Like",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }   
                        
                    </xsl:when>
                    
                    <xsl:when test="Type='int'">
                        
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>(int val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }  
        
        
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_GreaterThan(int val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>_GreaterThan",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }  
        
        
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_LessThan(int val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>_LessThan",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        } 
                        
                    </xsl:when>
                    
                    
                    <xsl:when test="Type='double'">
                        
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>(double val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }  
        
        
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_GreaterThan(double val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>_GreaterThan",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        }  
        
        
        public static <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_LessThan(double val) {
            ArrayList al<xsl:value-of select="$Name"/>=new ArrayList();
            try {
                using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
                    sqlCon.Open();
                    using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>_<xsl:value-of select="Name"/>_LessThan",sqlCon)) {
                        sqlCom.CommandType=CommandType.StoredProcedure;
                        sqlCom.Parameters.Add("@val",val);
                        using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
                            while(sqlDr.Read()) {
                                al<xsl:value-of select="$Name"/>.Add(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0)));
                            }
                        }
                    
                    }
                
                    sqlCon.Close();
                }
            }
            catch(Exception ex) {
                <xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.ReportException(ex);
            }
            return (<xsl:value-of select="$Name"/>[])al<xsl:value-of select="$Name"/>.ToArray(typeof(<xsl:value-of select="$Name"/>));
        } 
                        
                    </xsl:when>                    
                </xsl:choose>
            </xsl:if>
        </xsl:for-each>
        #endif
        
        
        
        
		<xsl:apply-templates select="ClassAttribs"/>
        
        
        <xsl:if test="count(ClassAttribs/ClassAttributes[Compare='true'])=0">
        public int CompareTo(object obj) {
            return ((<xsl:value-of select="Name"/>)obj).CreatedDate.CompareTo(CreatedDate);
        }         
        </xsl:if>
		
		
		
		#if(AJAX || AJAXPRO)
		// do not forget to Ajax.Utility.RegisterTypeForAjax(AJAX<xsl:value-of select="Name"/>)
        #if(AJAX)
		[AjaxStub.GRB.ComplexType()]
        #endif
		[Serializable()]
        #if(AJAXPRO)
        [AjaxPro.AjaxNamespace("<xsl:value-of select="Name"/>AJAX")]
        #endif
		public class <xsl:value-of select="Name"/>AJAX : <xsl:value-of select="Name"/> {
        
            // used for getting the JSON layout of the object
            // which we will use when creating new items and saving them
		    [AjaxMethod()]
            public <xsl:value-of select="Name"/> GetClass() {
                return new <xsl:value-of select="Name"/>();
            }
        
        
			[AjaxMethod()]
			public new <xsl:value-of select="Name"/>Small[] GetSmall() {
				return <xsl:value-of select="Name"/>.GetSmall();
			}
			
            
			[AjaxMethod()]
			public <xsl:value-of select="Name"/> GetItem(string id) {
				return new <xsl:value-of select="Name"/>(new Guid(id));
			}
			
			[AjaxMethod()]
			public new <xsl:value-of select="Name"/>[] Get() {
				return <xsl:value-of select="Name"/>.Get();
			}
			
			[AjaxMethod()]
			public string SaveAJAX(<xsl:value-of select="Name"/>AJAX obj) {
                obj.dirty=true;
				if(!obj.Save()) return "FAIL";
				return obj.objectID.ToString();
			}
            
            
            [AjaxMethod()]
            public bool Delete(<xsl:value-of select="Name"/>AJAX obj) {
                return obj.delete();
            }
            
            
            [AjaxMethod()]
            public bool DeleteID(string id) {
                return new <xsl:value-of select="Name"/>(new Guid(id)).delete();
            }
			
			
			
			<xsl:for-each select="ClassAttribs/ClassAttributes">
				<xsl:if test="ToString='true'">
			[AjaxMethod()]
			public static <xsl:value-of select="$Name"/>Small[] Search(string val) {
				return <xsl:value-of select="$Name"/>Small.Search(val);
			}
				</xsl:if>
            </xsl:for-each>    
        
        
            #if(PARAMFULL_AJAX)
            // This section contains parameter defined instances that
            // may or may not be used
            <xsl:for-each select="ClassAttribs/ClassAttributes">    
                <xsl:if test="CType='array'">
                    
            [AjaxMethod()]
            [Summary("Add a <xsl:value-of select="PropertyName"/> object to this <xsl:value-of select="$Name"/>")]
            public bool AddLink<xsl:value-of select="PropertyName"/>(Guid addObjID, Guid thisID) {
                <xsl:value-of select="$Name"/> _thisObj=new <xsl:value-of select="$Name"/>(thisID);
                
                <xsl:value-of select="Type"/> addition=new <xsl:value-of select="Type"/>(addObjID);
                
                if(!<xsl:value-of select="$HeaderInfo"/>.Utils.Contains(
                    (object[])_thisObj.<xsl:value-of select="PropertyName"/>.ToArray(typeof(object)),
                    addition)) {
                    
                    _thisObj.<xsl:value-of select="PropertyName"/>.Add(addition);
                    _thisObj.dirty=true;
                    return _thisObj.Save();
                } else {
                    return true;
                }
            }
                    
                </xsl:if>
            
                <xsl:if test="CType='single'">
                    <xsl:choose>
                        <xsl:when test="Type='bool'">
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>AJAX(bool val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>(val);
            }
                        </xsl:when>
                        
                        <xsl:when test="Type='DateTime'">
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>AJAX(DateTime val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>(val);
            }
            
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_BeforeAJAX(DateTime val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>_Before(val);
            }
            
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_AfterAJAX(DateTime val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>_After(val);
            }
            
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_BetweenAJAX(DateTime start,DateTime end) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>_Between(start,end);
            }
                        </xsl:when>
                        
                        <xsl:when test="Type='string' and SqlSPType!='ntext'">
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>AJAX(string val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>(val);
            }
                 
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_LikeAJAX(string val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>_Like(val);
            }
                        </xsl:when>
                        
                        <xsl:when test="Type='int'">
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>AJAX(int val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>(val);
            }  
                
                
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_LessThanAJAX(int val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>_LessThan(val);
            }  
            
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_GreaterThanAJAX(int val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>_GreaterThan(val);
            }  
                        </xsl:when>
                        
                        
                        <xsl:when test="Type='double'">
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>AJAX(double val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>(val);
            }  
                
                
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_LessThanAJAX(double val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>_LessThan(val);
            }  
            
            [AjaxMethod()]
            public <xsl:value-of select="$Name"/>[] Get_<xsl:value-of select="PropertyName"/>_GreaterThanAJAX(double val) {
                return <xsl:value-of select="$Name"/>.Get_<xsl:value-of select="PropertyName"/>_GreaterThan(val);
            }  
                        </xsl:when>
                        
                        
                    </xsl:choose>
                </xsl:if>
           
           </xsl:for-each>
           #endif       
                
			
		}
		#endif		
		
		
		

	[Serializable]
    #if(AJAX)
    [AjaxStub.GRB.ComplexType()]
    #endif
	public class <xsl:value-of select="Name"/>Small {
		private Guid objectID;
		public Guid ObjectID {
			get { return objectID; }
			set { objectID=value; }
		}
		
		public <xsl:value-of select="Name"/>Small() {}
		
		<xsl:for-each select="ClassAttribs/ClassAttributes">
			<xsl:if test="ToString='true'">
		private <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="Name"/>;
		
		
		public <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="PropertyName"/> {
			get { return <xsl:value-of select="Name"/>; }
			set { <xsl:value-of select="Name"/>=value; }
		}
        
        public string ToStringAJAX {
            get {
                return this.ToString();
            }
            set { int p=0xf; p--; }
        }
		
				
		public override string ToString() { return <xsl:value-of select="Name"/>.ToString(); }
			</xsl:if>
		</xsl:for-each>
		
		
		public static <xsl:value-of select="Name"/>Small[] LoadUsingFullSQL ( string sql )
		{
			ArrayList objResults=new ArrayList();
			using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
				sqlCon.Open();
				using(SqlCommand sqlCom=new SqlCommand(sql,sqlCon)) {			
					using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
						while(sqlDr.Read()) {
							objResults.Add(new <xsl:value-of select="$Name"/>Small(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0))));
						}
					}
				}
				sqlCon.Close();
			}
			return (<xsl:value-of select="$Name"/>Small[])objResults.ToArray(typeof(<xsl:value-of select="$Name"/>Small));
		
		}
		
		
		<xsl:for-each select="ClassAttribs/ClassAttributes">
			<xsl:if test="ToString='true'">
		public static <xsl:value-of select="$Name"/>Small[] Search(string searchString) {
			ArrayList objResults=new ArrayList();
			using(SqlConnection sqlCon=new SqlConnection(<xsl:value-of select="//HeaderInfo/ProjectName"/>DataObject.GetDB())) {
				sqlCon.Open();
				using(SqlCommand sqlCom=new SqlCommand("GENSP_<xsl:value-of select="//HeaderInfo/Prefix"/>_<xsl:value-of select="$Name"/>Search",sqlCon)) {			
					sqlCom.CommandType=CommandType.StoredProcedure;
					sqlCom.Parameters.Add("@searchString",searchString);
					using(SqlDataReader sqlDr=sqlCom.ExecuteReader()) {
						while(sqlDr.Read()) {
							objResults.Add(new <xsl:value-of select="$Name"/>Small(new <xsl:value-of select="$Name"/>(sqlDr.GetGuid(0))));
						}
					}
				}
				sqlCon.Close();
			}
			return (<xsl:value-of select="$Name"/>Small[])objResults.ToArray(typeof(<xsl:value-of select="$Name"/>Small));
		}
		
		
		
			</xsl:if>
		</xsl:for-each>			
		
		
		public <xsl:value-of select="Name"/>Small(<xsl:value-of select="Name"/> obj) {
			this.objectID=obj.ObjectID;
		<xsl:for-each select="ClassAttribs/ClassAttributes">
			<xsl:if test="ToString='true'">
			this.<xsl:value-of select="Name"/>=obj.<xsl:value-of select="PropertyName"/>;
			</xsl:if>
		</xsl:for-each>			
		}
		
		
	}			
		
	}
	
	
	

}
		
	</xsl:template>
	
	
	<xsl:template match="ClassAttribs">
		// fields and attributes of the system
#region Fields and Properties
		<xsl:apply-templates select="ClassAttributes"/>
#endregion
	</xsl:template>
	
	
	<xsl:template match="ClassAttributes">
		<xsl:if test="CType='single' and Type!='DateTime'">
		protected <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="Name"/><xsl:if test="Type='DateTime'">=DateTime.Now</xsl:if><xsl:if test="KnownClass='true'">=new <xsl:value-of select="Type"/>()</xsl:if><xsl:if test="Type='string'">=""</xsl:if>;
		[Sequence(<xsl:value-of select="position()"/>)]
		public <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="PropertyName"/> {
			get { return <xsl:value-of select="Name"/>; }
			set { base.dirty=true; this.<xsl:value-of select="Name"/>=value; }
		}
		</xsl:if>
        
        <xsl:if test="CType='single' and Type='DateTime'">
		protected <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="Name"/><xsl:if test="Type='DateTime'">=DateTime.Now</xsl:if><xsl:if test="KnownClass='true'">=new <xsl:value-of select="Type"/>()</xsl:if><xsl:if test="Type='string'">=""</xsl:if>;
		[Sequence(<xsl:value-of select="position()"/>)]
		public <xsl:value-of select="Type"/><xsl:text> </xsl:text><xsl:value-of select="PropertyName"/> {
			get  { return <xsl:value-of select="Name"/>.AddMinutes ( timezoneOffset ); } 

			set 
			{ 
				base.dirty=true; 
				<xsl:value-of select="Name"/> = value;
				//this.<xsl:value-of select="Name"/>.AddMinutes ( timezoneOffset * -1 );
			}
                
		}
		
		public string<xsl:text> </xsl:text><xsl:value-of select="PropertyName"/>_Nice { get { return <xsl:value-of select="Name"/>.ToString ( "dd-MMM-yy HH:mm"); } set {} }
		
		public Int64 <xsl:value-of select="PropertyName"/>_Ticks { get { return <xsl:value-of select="Name"/>.Ticks; } set {} }
		</xsl:if>
		
		<xsl:if test="Type='double'">
		public string <xsl:value-of select="PropertyName"/>_Sep { get { return <xsl:value-of select="Name"/>.ToString ( "N" ).Split ( '.' ) [ 0 ]; } set {} }
		</xsl:if>
		
		<xsl:if test="CType='array'">
		protected ArrayList <xsl:value-of select="Name"/>=new ArrayList();
		
		[ALAttrib(typeof(<xsl:value-of select="Type"/>))]
		#if(AJAX)
		[AjaxStub.GRB.ComplexArrayTypes(typeof(<xsl:value-of select="Type"/>))]
		#endif
		[XmlArrayItem("<xsl:if test="substring(PropertyName,string-length(PropertyName),1)='s'"><xsl:value-of select="substring(PropertyName,1,string-length(PropertyName)-1)"/></xsl:if><xsl:if test="substring(PropertyName,string-length(PropertyName),1)!='s'"><xsl:value-of select="PropertyName"/>_</xsl:if>",typeof(<xsl:value-of select="Type"/>))]
		[Sequence(<xsl:value-of select="position()"/>)]
		public ArrayList <xsl:value-of select="PropertyName"/> {
			get { return <xsl:value-of select="Name"/>; }
			set { base.dirty=true; this.<xsl:value-of select="Name"/>=value; }
		}	
		</xsl:if>
		
		<xsl:if test="ToString='true'">
		public override string ToString() { return <xsl:value-of select="Name"/>.ToString(); }
		</xsl:if>
        
        
        <xsl:if test="Compare='true'">
        public int CompareTo(object obj) {
            return ((<xsl:value-of select="/Class/Name"/>)obj).<xsl:value-of select="PropertyName"/>.CompareTo(<xsl:value-of select="Name"/>);
        }
        </xsl:if>
        
        
        

	</xsl:template>
</xsl:stylesheet>